package com.patterns.demo.singleton;

import java.util.Vector;

/**
 * Author: SamGroves
 * <p>
 * Description:
 * <p>
 * Date: 2017/11/28
 */
public class Singleton4 {

    private static Singleton4 instance = null;
    private Vector properties = null;

    public Vector getProperties() {
        return properties;
    }

    public Singleton4() {
    }

    private static synchronized void syncInit() {
        if (instance == null) {
            instance = new Singleton4();
        }
    }

    public static Singleton4 getInstance() {
        if (instance == null) {
            syncInit();
        }
        return instance;
    }

    // 实现同步更新
    public void updateProperties() {
        Singleton4 shadow = new Singleton4();
        properties = shadow.getProperties();
    }
}
